<?php
/**
 * XmuSlh, web platform of Student Association Federation of Xiamen University
 * 
 * Rewritting one or some pages of StatusNet. 
 * To get the original version, please visit <http://status.net/>.
 * 
 * StatusNet, the distributed open-source microblogging tool
 * 
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Addassociationuser action form.
 * 添加社团用户的表格.
 * 
 * @author		ytukie <ytukie@gmail.com>
 * @version		0.3
 * 
 * 0.2)  Adds the 'categoroy' selection.
 * 0.3)  Adds the editor feature.
 */

// XmuSlh only.
if ( !defined('XMUSLH')) { exit(1); }

// Requirements.
require_once INSTALLDIR . '/lib/slh_form.php';
require_once INSTALLDIR . '/lib/slh_editor.php';

require_once INSTALLDIR . '/classes/Association.php';


class AddassociationuserForm extends Form
{
	/**
	 * The editor widget.
	 */
	var $editor;
	
	function prepareData()
	{
		$this->editor = new Editor('rendered', $this->out);
	}
	
	/**
	 * ID of the from
	 */
	function id()
	{
		return 'id_form_addassociationuser';
	}
	
	/**
	 * Class of the form.
	 */
	/*
	function formClass()
	{
	}
	*/
	
	/**
	 * Action of the form
	 * 
	 * Return the string URL of the action.
	 */
	function action()
	{
		return slh_action2url('addassociationuser');
	}
	
	/**
	 * Name of the form
	 */
	function formLegend()
	{
		$this->out->element('legend', null, 'add association');
	}
	
	/**
	 * Data elements.
	 */
	function formData()
	{
		$this->out->elementStart('dl', array('class' => 'cls_dl_form'));
		
		$this->out->element('dt', null, '账户信息');
		$this->out->elementStart('dd');
		$this->out->elementStart('ul');
			$this->out->elementStart('li');
			$this->out->input('username',
							  '用户名',
							  $this->getField('username'),
							  '登录时输入的用户名');
			$this->out->elementEnd('li');
			
			$this->out->elementStart('li');
			$this->out->readonly('password',
							  	 '密码',
							  	 '与用户名相同');
			$this->out->elementEnd('li');
		$this->out->elementEnd('ul');
		$this->out->elementEnd('dd');
		
		$this->out->element('dt', null, '社团信息');
		$this->out->elementStart('dd');
		$this->out->elementStart('ul');
			$this->out->elementStart('li');
			$this->out->element('label', array('for' => 'category'), '社团分类');
			$this->out->elementStart('select', array('id' => 'category',
													 'name' => 'category'));
			foreach(Association::$categories as $name => $value) {
				if ($value == $this->getField('category')) {
					$this->out->element('option', array('value' => $value,
														'selected' => 'selected'), $name);
				} else {
					$this->out->element('option', array('value' => $value), $name);
				}
			}
			$this->out->elementEnd('select');
			$this->out->inputtips('选择社团的种类哦.'); 
			$this->out->elementEnd('li');
			
			$this->out->elementStart('li');
			$this->out->input('cnname',
							  '中文名称',
							  $this->getField('cnname'),
							  '社团完整的中文名称.');
			$this->out->elementEnd('li');
			
			$this->out->elementStart('li');
			$this->out->input('enname',
							  '英文名称', 
							  $this->getField('enname'),
							  '[选填]有就可以填上哦,亲.');
			$this->out->elementEnd('li');
			
			$this->out->elementStart('li');
			$this->out->input('pinyin',
							  '中文拼音', 
							  $this->getField('pinyin'),
							  '[选填]用于简化查找呃.');
			$this->out->elementEnd('li');
			
			$this->out->elementStart('li');
			$this->out->input('weibo_id',
							  '新浪微博id', 
							  $this->getField('weibo_id'),
							  '[选填]可以用来更新显示社团微博的最新内容.');
			$this->out->elementEnd('li');
			
			$this->out->element('dt', null, '社团的简介');
			$this->out->inputtips('[选填]社团的基本情况和相关说明啦.');
			$this->out->elementStart('li', 'cls_li_eaditor');
			$this->editor->show();
			$this->out->elementEnd('li');
			
			/*
			$this->out->elementStart('li');
			$this->out->textarea('rendered',
								 '社团的简介',
								 6,
								 72,
								 $this->getField('rendered'),
								 '[选填]社团的基本情况和相关说明啦.');
			$this->out->elementEnd('li');
			*/
		$this->out->elementEnd('ul');
		$this->out->elementEnd('dd');
		
		$this->out->elementEnd('dl');
	}
	
	/**
	 * Action elements.
	 */
	function formActions()
	{
		$this->out->elementStart('div', 'formaction');
		$this->out->submit('submit',
						   '添加',
						   'submit',
						   'add',
						   '添加一个社团用户.');
		$this->out->elementEnd('div');
	}
}